package com.fz.util;


import lombok.Data;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by webrx on 2017/6/27.
 */
@Data
public class Dbutil {
    protected SqlSessionFactory sf;
    protected SqlSession session;

   /* public DbHeper() {
        try {
            this.sf = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis01-confing.xml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        this.ss = this.sf.openSession();
    }
    public SqlSession getSession(){
        return this.ss;
    }*/

    public Dbutil() throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        this.sf = new SqlSessionFactoryBuilder().build(inputStream);
        this.session = this.sf.openSession();

    }



}
